Add experimental introspection support.
authorPhilipp Sadleder <philipp@sadleder.de>
Mon, 12 Jul 2010 14:49:12 +0000 (16:49 +0200)
committerPhilipp Sadleder <philipp@sadleder.de>
Mon, 12 Jul 2010 14:49:12 +0000 (16:49 +0200)
Disabled by default; use --enable-introspection to enable it.

ChangeLog.pre-0-1
Makefile.am
autogen.sh
babl/Makefile.am
configure.ac
m4/introspection.m4 [new file with mode: 0644]

index 14711c171886620477e225acc6c71bd375f9175f..a81c443a62fedb64fffe57a251260ce1da720872 100644 (file)
@@ -1,4 +1,3 @@
-
 =========================== 0.1.0 released =============================
 
 2009-05-20  Martin Nordholts  <martinn@src.gnome.org>
index 8e95d7a20dd80041b16008b0d980bfb48bed8c54..23b9f8a051572bfddff7a54c074fc2a47df4b71d 100644 (file)
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS = -I m4
+DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
 AUTOMAKE_OPTIONS = foreign dist-bzip2
 
 SUBDIRS = \
@@ -21,7 +23,8 @@ EXTRA_DIST = \
        TODO                    \
        ChangeLog               \
        autogen.sh              \
-       babl.pc.in
+       babl.pc.in              \
+       m4/introspection.m4
 
 DISTCLEANFILES = \
        $(built_dist_files)     \
index a149e4eec5a93f23f4a68aa664c938cb8f1449b4..cd9712b296f2dcd4fd546c9ea50ecf7dc0ce5728 100755 (executable)
@@ -9,10 +9,10 @@
 # tools and you shouldn't use this script.  Just call ./configure
 # directly.
 
-ACLOCAL=${ACLOCAL-aclocal-1.9}
+ACLOCAL=${ACLOCAL-aclocal}
 AUTOCONF=${AUTOCONF-autoconf}
 AUTOHEADER=${AUTOHEADER-autoheader}
-AUTOMAKE=${AUTOMAKE-automake-1.9}
+AUTOMAKE=${AUTOMAKE-automake}
 LIBTOOLIZE=${LIBTOOLIZE-libtoolize}
 
 AUTOCONF_REQUIRED_VERSION=2.54
index 12cd9694336d147ea65af342d1029b1ce546d409..3f061fa347678d4d89dd6af3c0f73b347bcb90ca 100644 (file)
@@ -81,3 +81,41 @@ libbabl_@BABL_API_VERSION@_la_LIBADD=\
 libbabl_@BABL_API_VERSION@_la_LDFLAGS=                 \
        ${no_undefined} $(MATH_LIB)     \
        -version-info $(BABL_LIBRARY_VERSION)
+
+# GObject Introspection
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+Babl-$(BABL_API_VERSION).gir: $(G_IR_SCANNER)
+       $(INTROSPECTION_SCANNER) -v --namespace Babl --nsversion=$(BABL_API_VERSION) \
+            --add-include-path=$(srcdir) --add-include-path=. \
+            --library=babl-$(BABL_API_VERSION) \
+            --libtool="$(LIBTOOL)" \
+            --output $@ \
+            --pkg babl \
+           -I$(top_srcdir) \
+           -I$(top_builddir) \
+           $(library_include_HEADERS) \
+           $(c_sources)
+
+girdir = $(INTROSPECTION_TYPELIBDIR)
+gir_DATA = Babl-$(BABL_API_VERSION).gir
+
+typelibsdir = $(INTROSPECTION_TYPELIBDIR)
+typelibs_DATA = Babl-$(BABL_API_VERSION).typelib
+
+EXTRA_DIST = $(gir_DATA)
+CLEANFILES = $(gir_DATA) $(typelibs_DATA)
+
+%.typelib: %.gir
+       LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. $(INTROSPECTION_COMPILER) \
+        --includedir=$(srcdir) \
+        --includedir=$(top_builddir)/babl \
+        $(G_IR_COMPILER_OPTS) \
+        $< -o $@
+
+
+endif # HAVE_INTROSPECTION
index 970896f36f0fcc7c60fa0b967730120b882e9f33..0a46daaeb51af07b070ecbffef529cd896dbe20e 100644 (file)
@@ -37,6 +37,7 @@ m4_define([babl_stable],
 
 AC_INIT(babl, babl_major_version.babl_minor_version.babl_micro_version)
 AC_CONFIG_SRCDIR(babl/babl.h)
+AC_CONFIG_MACRO_DIR([m4])
 
 # Enable silent build rules by default, requires at least
 # Automake-1.11. Disable by either passing --disable-silent-rules to
@@ -63,6 +64,8 @@ AC_SUBST(BABL_API_VERSION)
 BABL_RELEASE=babl_api_version
 AC_SUBST(BABL_RELEASE)
 
+# GObject Introspection
+GOBJECT_INTROSPECTION_CHECK([0.6.8])
 
 dnl The symbol BABL_UNSTABLE is defined above for substitution in
 dnl Makefiles and conditionally defined here as a preprocessor symbol
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644 (file)
index 0000000..589721c
--- /dev/null
@@ -0,0 +1,94 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+    ],dnl
+    [dnl       
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])